/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.ds2.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Eli
 */
@Entity
@Table(name = "discs")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Discs.findAll", query = "SELECT d FROM Discs d"),
    @NamedQuery(name = "Discs.findByIdDisc", query = "SELECT d FROM Discs d WHERE d.idDisc = :idDisc"),
    @NamedQuery(name = "Discs.findByBarcode", query = "SELECT d FROM Discs d WHERE d.barcode = :barcode"),
    @NamedQuery(name = "Discs.findByArtist", query = "SELECT d FROM Discs d WHERE d.artist = :artist"),
    @NamedQuery(name = "Discs.findByTitle", query = "SELECT d FROM Discs d WHERE d.title = :title"),
    @NamedQuery(name = "Discs.findByPrice", query = "SELECT d FROM Discs d WHERE d.price = :price"),
    @NamedQuery(name = "Discs.findByExistence", query = "SELECT d FROM Discs d WHERE d.existence = :existence")})
public class Discs implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idDisc")
    private Integer idDisc;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "barcode")
    private String barcode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "artist")
    private String artist;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "title")
    private String title;
    @Basic(optional = false)
    @NotNull
    @Column(name = "price")
    private float price;
    @Basic(optional = false)
    @NotNull
    @Column(name = "existence")
    private int existence;
    @JoinColumn(name = "idgenre", referencedColumnName = "idgenre")
    @ManyToOne(optional = false)
    private MusicalGenres idgenre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDisc")
    private Collection<SaleDetails> saildetailsCollection;

    public Discs() {
    }

    public Discs(Integer idDisc) {
        this.idDisc = idDisc;
    }

    public Discs(Integer idDisc, String barcode, String artist, String title, float price, int existence) {
        this.idDisc = idDisc;
        this.barcode = barcode;
        this.artist = artist;
        this.title = title;
        this.price = price;
        this.existence = existence;
    }

    public Integer getIdDisc() {
        return idDisc;
    }

    public void setIdDisc(Integer idDisc) {
        this.idDisc = idDisc;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public int getExistence() {
        return existence;
    }

    public void setExistence(int existence) {
        this.existence = existence;
    }

    public MusicalGenres getIdgenre() {
        return idgenre;
    }

    public void setIdgenre(MusicalGenres idgenre) {
        this.idgenre = idgenre;
    }

    @XmlTransient
    public Collection<SaleDetails> getSaildetailsCollection() {
        return saildetailsCollection;
    }

    public void setSaildetailsCollection(Collection<SaleDetails> saildetailsCollection) {
        this.saildetailsCollection = saildetailsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDisc != null ? idDisc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Discs)) {
            return false;
        }
        Discs other = (Discs) object;
        if ((this.idDisc == null && other.idDisc != null) || (this.idDisc != null && !this.idDisc.equals(other.idDisc))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mx.itsc.ds2.model.Discs[ idDisc=" + idDisc + " ]";
    }
    
}
